
import time

import yaml
from uiautomator2 import xpath


from page_object.guang_page import GuangPage
from resource.client_path_info import *
from resource.path_info import *

"""
C端用户进入爱逛直播
"""
class ClientLivingPage(GuangPage):
    """
    查看直播状态
    """
    def check_living_status(self, d, expectedName):
        print("check_living_status")
        d.xpath(client_main_follow_xpath).click()
        time.sleep(1)
        d.xpath(client_living_xpath).click()
        time.sleep(5)
        if d.xpath(client_red_close_xpath).exists:
            d.xpath(client_red_close_xpath).click()
        time.sleep(1)
        living_name = d.xpath(client_living_anchorName_xpath).get_text()
        assert living_name == expectedName
        return self

    """
    進入直播間
    """

    def check_guang_live(self, d, showing_goodsName):
        print("check_guang_live")
        #查看上屏
        d.xpath(client_living_goodName_xpath).wait(timeout=30.0)
        living_good_name = d.xpath(client_living_goodName_xpath).get_text()
        assert living_good_name == showing_goodsName
        #查看貼紙
        if d.xpath(client_living_sticker_xpath).exists:
            print("check sticker successfully")
        else:
            raise Exception("check sticker fail")
        return self
















